package com.game.battleship.data;

/**
 * @author vtkhanh
 *
 */
public class ShipsStatus {	
	
	private static final int ATTACK_CONSTANT = Game.BOARD_SIZE;
	private static final int WATER_ATTACKED = Game.WATER - ATTACK_CONSTANT;
	
	/**
	 * 
	 * @param 	code:		status of a position
	 * @return	whether a water position is ATTACKED
	 */
	public static boolean isWaterAttackedStatus(short code) {
		return code == WATER_ATTACKED;
	}
	/**
	 * @param 	code:	status of a ship
	 * @return 	whether a ship is ATTACKED
	 */
	public static boolean isShipAttackedStatus(short code) {
		return (isAttackedStatus(code) && (!isWaterAttackedStatus(code)));
	}	
	
	/**
	 * @param 	code: status of a spot on board
	 * @return 	whether a spot has been attacked already
	 */
	public static boolean isAttackedStatus(short code) {
		return code < 0;
	}

	/**
	 * @param 	code:	previous code of attacked spot
	 * @return 	new code of attacked spot
	 */
	public static short getAttackedCode(short code) {
		if (code > 0) {
			return (short) (code - ATTACK_CONSTANT);
		}
		return code;
	}
	
	/*public static short getShipMarkerCode(short shipIndex){
		short boardMarker;
		switch (shipIndex) {		
		case 1:
			boardMarker = Game.SHIP_1;
			break;
		case 2:
			boardMarker = Game.SHIP_2;
			break;
		case 3:
			boardMarker = Game.SHIP_3;
			break;
		case 4:
			boardMarker = Game.SHIP_4;
			break;

		default:
			boardMarker = -1;
			break;
		}
		return boardMarker;		
	}*/
}
